#include "utils.hpp"
#include "level.hpp"
#include "formater.hpp"
#include "message.hpp"
#include "sink.hpp"
#include "logger.hpp"

int main()
{
    std::string logger_name = "Sync_logger";
    wzh::LogLevel::value limit = wzh::LogLevel::value::WARN;
    wzh::Formatter::ptr fmt(new wzh::Formatter("[%d{%H:%M:%S}][%c][%d:%l][%p]%T%m%n"));
    wzh::LogSink::ptr lsp_out = wzh::SinkFactory::create<wzh::StdoutSink>();
    wzh::LogSink::ptr lsp_file = wzh::SinkFactory::create<wzh::FileSink>("./logfile/test.log");
    wzh::LogSink::ptr lsp_roll = wzh::SinkFactory::create<wzh::RollSink>("./logfile/roll-", 1024 * 1024);
    std::vector<wzh::LogSink::ptr> sinks = {lsp_out, lsp_file, lsp_roll};
    wzh::Logger::ptr logger(new wzh::SyncLogger(logger_name, fmt, sinks, limit));

    // size_t cursize = 0;
    // int count = 0;
    // while (cursize <= 1024 * 1024 * 10)
    // {
    //     std::string tmp = str + std::to_string(count++);
    //     lsp_roll->log(tmp.c_str(), tmp.size());
    //     cursize += tmp.size();
    // }

    // wzh::LogMsg msg("root", "main.cc", 53, "测试...", wzh::LogLevel::value::INFO);
    // wzh::Formatter fmt;
    // std::string str = fmt.format(msg);
    // // std::cout << str << std::endl;
    // wzh::LogSink::ptr lsp_out = wzh::SinkFactory::create<wzh::StdoutSink>();
    // wzh::LogSink::ptr lsp_file = wzh::SinkFactory::create<wzh::FileSink>("./logfile/test.log");
    // wzh::LogSink::ptr lsp_roll = wzh::SinkFactory::create<wzh::RollSink>("./logfile/roll-", 1024 * 1024);
    // lsp_out->log(str.c_str(), str.size());
    // lsp_file->log(str.c_str(), str.size());
    // size_t cursize = 0;
    // int count = 0;
    // while(cursize <= 1024 * 1024 * 10)
    // {
    //     std::string tmp = str + std::to_string(count++);
    //     lsp_roll->log(tmp.c_str(), tmp.size());
    //     cursize += tmp.size();
    // }
    // std::cout << wzh::LogLevel::toString(wzh::LogLevel::value::DEBUG) << std::endl;
    // std::cout << wzh::LogLevel::toString(wzh::LogLevel::value::ERROR) << std::endl;
    // std::cout << wzh::LogLevel::toString(wzh::LogLevel::value::FATAL) << std::endl;
    // std::cout << wzh::LogLevel::toString(wzh::LogLevel::value::INFO) << std::endl;
    // std::cout << wzh::LogLevel::toString(wzh::LogLevel::value::OFF) << std::endl;
    // std::cout << wzh::LogLevel::toString(wzh::LogLevel::value::UNKNOW) << std::endl;
    // std::cout << wzh::LogLevel::toString(wzh::LogLevel::value::WARN) << std::endl;

    // std::cout << wzh::util::Date::now() << std::endl;

    // std::string pathname = "./abc/bcd/a.txt";
    // wzh::util::file::create_directory(wzh::util::file::path(pathname));
    return 0;
}